﻿LApp.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider.state('Default', {
        url: '',
        templateUrl: CONTENT_URL('Pages/default.html')
    });

    $stateProvider.state('Tools', {
        url: '/Tools/1',
        templateUrl: CONTENT_URL('Pages/Tools1.html'),
        controller: 'Tools1Ctrl'
    });

    $stateProvider.state('Account_LogOn', {
        url: '/Account/LogOn',
        templateUrl: CONTENT_URL('Pages/Account/LogOn.html'),
        controller: 'Account_LogOnCtrl'
    });

    $stateProvider.state('Manager', {
        url: '/Manager',
        templateUrl: CONTENT_URL('Pages/Layout_Manager.html'),
        controller: 'ManagerCtrl'
    });

    //nb
    $stateProvider.state('Manager.NBHome', {
        url: '/NBManager/Home',
        templateUrl: CONTENT_URL('Pages/NBHome.html'),
        controller: 'NBManagerHomeCtrl'
    });

    $stateProvider.state('Manager.Home', {
        url: '/Manager/Home',
        templateUrl: CONTENT_URL('Pages/Home.html'),
        controller: 'ManagerHomeCtrl'
    });

    $stateProvider.state('Manager.Test_Test1', {
        url: '/Test/Test1',
        templateUrl: CONTENT_URL('Pages/Test/Test1.html'),
        controller: 'Test1Ctrl'
    });

    

    //angular.forEach(window.MenuList, function (item) {
    //    if (item.MutilState == true) return;
    //    if (item.StateName) {
    //        $stateProvider.state(item.StateName, {
    //            url: item.Url,
    //            templateUrl: item.TemplateUrl,
    //            controller: item.Controller
    //        });
    //    }
    //})
    var _stateArray = [];
    angular.forEach(window.MenuList, function (item) {
        if (item.MenuCode) {
            item.StateName = 'Manager.' + item.Belong + '_' + item.MenuCode;

            if (_stateArray.indexOf(item.StateName) != -1) return;
            _stateArray.push(item.StateName);

            if (!item.Url) item.Url = '/' + item.Belong + '/' + item.MenuCode


            $stateProvider.state(item.StateName, {
                ParentMenuID: item.ParentMenuID,
                MenuID: item.MenuID,
                url: item.Url,
                templateUrl: CONTENT_URL(item.TemplateUrl),
                controller:item.Belong + '_' + item.MenuCode +'Ctrl'
            });
        }
    })
})